import request from '../utils/request';

// 获取所有频道列表
export const getChannelsAPI = () =>
  request({
    url: '/v1_0/channels',
  });

// 获取文章列表
export const getArticlesAPI = (params) =>
  request({
    url: '/v1_0/mp/articles',
    params,
  });

// 删除文章列表
export const delArticlesAPI = (id) =>
  request({
    url: '/v1_0/mp/articles/' + id,
    method: 'delete',
  });

// 发表文章
export const publicArticlesAPI = (data, draft) =>
  request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'POST',
    data,
  });

// 获取文章详情
export const getArticlesByIdAPI = (id) =>
  request({
    url: `/v1_0/mp/articles/${id}`,
  });

// 获取文章详情
export const editArticlesAPI = (data, draft) =>
  request({
    url: `/v1_0/mp/articles/${data.id}?draft=${draft}`,
    method: 'PUT',
    data,
  });
